You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Splitting formatter strings only on the substring " && " fails if users omit spaces around && or include multiple spaces; consider normalizing whitespace or splitting on '&&' with surrounding whitespace trimmed.
Using Path(...).relative_to(Path.cwd()) will raise a ValueError if the configured path is not under CWD; consider fallbacks like os.path.relpath with try/except or returning the absolute path.
The LSP default for formatter_cmds is a joined string, but choices likely expect a list; ensure downstream consumers handle the string default consistently with list-based choices.
Guard against non-subpath values to prevent ValueError from Path.relative_to when given absolute paths outside cwd or relative paths with "..". Fallback to the original string if not relative to cwd.
-configured_module_root = Path(server.args.module_root).relative_to(Path.cwd()) if server.args.module_root else None-configured_tests_root = Path(server.args.tests_root).relative_to(Path.cwd()) if server.args.tests_root else None+def _rel_to_cwd(p: str | None):+ if not p:+ return None+ try:+ return Path(p).resolve().relative_to(Path.cwd().resolve())+ except Exception:+ return p+configured_module_root = _rel_to_cwd(server.args.module_root)+configured_tests_root = _rel_to_cwd(server.args.tests_root)
Suggestion importance[1-10]: 8
__
Why: Using Path.relative_to can raise ValueError for paths outside cwd; adding a safe helper prevents runtime errors and preserves intended behavior, addressing a real edge case.
Medium
Trim split formatter commands
Trim each split command to avoid leading/trailing spaces that can break execution equality checks. This ensures consistent behavior regardless of user spacing around the delimiter.
if " && " in formatter:
- return formatter.split(" && ")+ return [cmd.strip() for cmd in formatter.split(" && ")]
Suggestion importance[1-10]: 6
__
Why: Trimming each split command improves robustness against user spacing and aligns with similar trimming elsewhere; it's correct and low-risk but a minor enhancement.
Low
General
Ignore empty formatter configs
Normalize empty or whitespace-only formatter values to None to avoid setting a misleading empty default. This preserves fallback to the detected default when no valid configuration is provided.
-configured_formatter = ""+configured_formatter = None
if isinstance(server.args.formatter_cmds, list):
- configured_formatter = " && ".join([cmd.strip() for cmd in server.args.formatter_cmds])+ cleaned = [cmd.strip() for cmd in server.args.formatter_cmds if cmd and cmd.strip()]+ configured_formatter = " && ".join(cleaned) if cleaned else None
elif isinstance(server.args.formatter_cmds, str):
- configured_formatter = server.args.formatter_cmds.strip()+ cleaned = server.args.formatter_cmds.strip()+ configured_formatter = cleaned if cleaned else None
Suggestion importance[1-10]: 7
__
Why: Normalizing empty values to None ensures fallback to defaults and avoids misleading empty strings; it's consistent with nearby logic and improves configuration handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement
Description
Use configured values as LSP defaults
Parse chained formatter commands with '&&'
Preserve formatter cmds from list or string
Keep suggestions choices unchanged
Diagram Walkthrough
File Walkthrough
cmd_init.py
Support chained formatter commands in initcodeflash/cli_cmds/cmd_init.py
beta.py
Use configured settings as LSP defaultscodeflash/lsp/beta.py